package com.qf.controller;

import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author 千锋教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/echo")
    public String index(ModelMap modelMap){
        //在请求域存储数据
        modelMap.put("name", "张金源");
        System.out.println("index");
        return "index";
    }


    @RequestMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }


    @RequestMapping("/findById")
    public User findById(Integer id){
        return userService.findById(id);
    }
}
